<template>
	<view>
		<view class="page-head">
			<view class="page-head-list">
				<view class="page-head-list-item">
					<strong class="page-head-list-item-num">{{totalMoney||0}}</strong>
					<view class="page-head-list-item-text">奖励</view>
				</view>
				<navigator open-type="navigate" hover-class="none" url="/pages/jewel/material/material_takecash?state=18" class="page-head-btn">退取</navigator>
			</view>
		</view>
		<view class="page-methods">
			<view class="page-methods-top">
				<view class="page-methods-top-text"><strong>奖励</strong>转入可退押金</view>
				<!-- <view class="page-methods-top-etext">最多可转<strong>￥100.00</strong></view> -->
			</view>
			<view class="page-methods-bottom">
				<text>￥</text>
				<input type="number" v-model="postMoney" placeholder="请输入转入金额" />
				<view class="page-methods-bottom-btn" @tap="showPay">转入</view>
			</view>
		</view>
		<view class="store-cont">
			<view class="store-cont-title"><view class="store-cont-title-text">历史明细</view></view>
			<view class="store-cont-list" v-for="(item,index) in orderList" :key="index">
				<view class="store-cont-list-item">
					<view class="store-cont-list-item-left">
						<view class="store-cont-list-item-left-text">{{item.remark}}</view>
						<view class="store-cont-list-item-left-time">{{item.create_time}}</view>
					</view>
					<view class="store-cont-list-item-right" :class="{red:item.way == 1}">{{item.way == 1?'+':'-'}}{{item.amount}}</view>
				</view>
			</view>
			<mix-load-more :status="loadMoreStatus"></mix-load-more>
		</view>
		<paymentPassword :show="isShowPay" digits="6" @confirm="confirm" @cancel="showPay"></paymentPassword>
	</view>
</template>

<script>
	import jewel from '@/common/common_zb.js';
	import md5 from '@/common/md5.js'
	export default {
		data() {
			return {
				orderList:[],
				page:1,
				total_pages:1,
				modeClass:['fade'],
				transShow:false,
				transfromClass: {
					'position': 'fixed',
					'bottom': 0,
					'top': 0,
					'left': 0,
					'right': 0,
					/* #ifndef APP-NVUE */
					'display': 'flex',
					/* #endif */
					'justify-content': 'center',
					'align-items': 'center',
					'z-index':11
				},
				maskClass: {
					'position': 'fixed',
					'z-index':9,
					'bottom': 0,
					'top': 0,
					'left': 0,
					'right': 0,
					'background-color': 'rgba(0, 0, 0, 0.4)'
				},
				loadMoreStatus:1,
				totalMoney:0,
				postMoney:'',
				isShowPay:false
			}
		},
		onShow() {
			this.page = 1
			this.getData()
		},
		methods: {
			getData(type){
				let that = this
				if(that.page <= that.total_pages){
					jewel.get('agent_jewel/getTypeLog',{page:that.page,type:18},true,function(res){
						if(type=='loadMore'){
							that.orderList = that.orderList.concat(res.data.data)
						}else{
							that.orderList = res.data.data
							that.total_pages = res.data.total_pages
							that.loadMoreStatus = that.total_pages <= 1 ? 2:0
							jewel.get('agent_jewel/getInfo',{},true,function(res){
								that.totalMoney = res.data.data.franchise_benefit
							})
						}
					})
				}else{
					that.loadMoreStatus = 2
				}
			},
			//下拉刷新
			onPulldownReresh(){
				this.page = 1
				this.totalPages = 1
				this.loadNewsList('refresh');
			},
			showPay(){
				if(!this.postMoney) return false
				this.isShowPay = !this.isShowPay
			},
			confirm(e){
				let that = this
				let data = {
					from_id:18,
					to_id:16,
					money:that.postMoney,
					paypwd:md5(e)
				}
				jewel.post('agent_jewel/toAccountChange',data,true,function(res){
					jewel.showToast(res.data.msg,res.data.code ==0?1500:3000)
					that.isShowPay = false
					if(res.data.code == 0){
						that.postMoney = ''
						that.page = 1
						that.getData()
					}
				})
			}
		},
		onReachBottom() {
			this.page++
			this.getData('loadMore')
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #fafafa;
		height: 100vh;
	}
	.page-head{
		background-image: linear-gradient(to bottom, #0aac2a , #0f7c08);
		text-align: center;
		color: #FFFFFF;
		padding: 50rpx 0;
		&-list{
			display: flex;
			justify-content: space-between;
			padding: 0 34rpx 0 60rpx;
			align-items: center;
			&-item{
				text-align: left;
				&-num{
					font-size: 50rpx;
					font-weight: bold;
				}
				&-text{
					font-size: 38rpx;
				}
			}
		}
		&-btn{
			width: 170rpx;
			text-align: center;
			line-height: 56rpx;
			height: 56rpx;
			border: 4rpx solid #FFFFFF;
			border-radius: 10rpx;
		}
	}
	.page-methods{
		background-color: #FFFFFF;
		padding: 30rpx 46rpx;
		&-top{
			&-text{
				font-size: 32rpx;
				strong{
					font-size: 38rpx;
					margin-right: 16rpx;
				}
			}
			&-etext{
				font-size: 30rpx;
				color: #767575;
				strong{
					color: #e72222;
				}
			}
		}
		&-bottom{
			display: flex;
			align-items: center;
			text{
				font-size: 58rpx;
				width: 34rpx;
				margin-left: -10rpx;
				margin-right: 28rpx;
			}
			input{
				height: 36rpx;
				font-size: 36rpx;
				padding: 20rpx 0;
				border-bottom: 1px solid #e8e8e8;
				width: 380rpx;
			}
			&-btn{
				width: 170rpx;
				line-height: 56rpx;
				text-align: center;
				color: #0c991d;
				font-size: 38rpx;
				border: 2px solid #0c991d;
				border-radius: 10rpx;
				margin-left: 40rpx;
			}
		}
	}
	.store-cont{
		&-title{
			display: flex;
			justify-content: center;
			align-items: center;
			padding-top: 26rpx;
			&-text{
				color: #666666;
				font-size: 28rpx;
				position: relative;
				&::before{
					content: '';
					position: absolute;
					width: 40rpx;
					height: 2rpx;
					background-color: #666666;
					left: -56rpx;
					top: 50%;
				}
				&::after{
					content: '';
					position: absolute;
					width: 40rpx;
					height: 2rpx;
					background-color: #666666;
					right: -56rpx;
					top: 50%;
				}
			}
		}
		&-list{
			padding: 0 30rpx;
			&-item{
				height: 115rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				border-bottom: 1px solid #e2e2e2;
				position: relative;
				&-left{
					&-text{
						font-size: 32rpx;
					}
					&-time{
						color: #adadad;
						font-size: 26rpx;
					}
				}
				&-right{
					color: #000000;
					font-size: 42rpx;
					font-weight: bold;
				}
				.red{
					color: #f65754;
				}
			}
		}
	}
	.store-btn{
		background-color: #FFFFFF;
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		padding: 28rpx 22rpx;
		box-sizing: border-box;
		&-text{
			color: #FFFFFF;
			background-color: #0aac2a;
			text-align: center;
			line-height: 85rpx;
			font-size: 36rpx;
			border-radius: 10rpx;
		}
	}
</style>
